<template>
	<view v-if="is_init">
		<uni-popup-input name="新增/编辑" @close="on_close">

			<view class="p-b-20">
				<view class="f-14 c-7" style="height: 40px;"><text class="cred">*</text>更新内容(禁止图片和视频)
				</view>
				<view class="p2 " style="width: 95%;border: solid 2rpx #c0c0c0;">
					<BmEditor @change="confirm_describe" :content="find.describe" mode="default" :height="350"
						placeholder="请输入内容"> </BmEditor>
				</view>
			</view>
			<view class="banmi_input_edit a-c">
				<view class="banmi_input_edit_name">
					<text class="cred">*</text>下载地址
				</view>
				<view class="banmi_input_val">
					<uni-easyinput v-model="find.edition_url" placeholder="请输入下载地址">
					</uni-easyinput>
				</view>
			</view>
			<view class="banmi_input_edit" style="margin-left: 220rpx;">
				<text class="cred f-14">*.apk或.wgt包下载地址或者应用市场地址,安卓应用市场,market://details?id=xxxx,苹果store
					itms-apps://itunes.apple.com/cn/app/xxxxxx</text>
			</view>
			<view class="banmi_input_edit a-c">
				<view class="banmi_input_edit_name">
					<text class="cred">*</text>版本号(示例100)
				</view>
				<view class="banmi_input_val">

					<uni-easyinput v-model="find.edition_number" type="number" placeholder="请输入版本号100">
					</uni-easyinput>
				</view>
			</view>
			<view class="banmi_input_edit" style="margin-left: 220rpx;">
				<text class="cred f-14">*版本号manifest里的应用版本号(小版本更新)</text>
			</view>
			<view class="banmi_input_edit a-c">
				<view class="banmi_input_edit_name">
					<text class="cred">*</text>版本名称(示例1.0.0)
				</view>
				<view class="banmi_input_val">
					<uni-easyinput v-model="find.edition_name" placeholder="请输入版本名称1.0.0">
					</uni-easyinput>
				</view>
			</view>
			<view class="banmi_input_edit" style="margin-left: 220rpx;">
				<text class="cred f-14">*版本名称 manifest里的版本名称(大版本更新)</text>
			</view>
			<view class="banmi_input_edit a-c">
				<view class="banmi_input_edit_name">
					<text class="cred">*</text>是否发行
				</view>
				<view class="banmi_input_val">
					<uni-data-checkbox :localdata="localdata_edition_issue" @change="change_edition_issue"
						:value="find.edition_issue" mode="default"></uni-data-checkbox>
				</view>
			</view>
			<view class="banmi_input_edit" style="margin-left: 220rpx;">
				<text class="cred f-14">*为了控制上架应用市场审核时不能弹出热更新框(审核不得弹出更新包)</text>
			</view>
			<view class="banmi_input_edit a-c">
				<view class="banmi_input_edit_name">
					<text class="cred">*</text>强制更新
				</view>
				<view class="banmi_input_val">
					<uni-data-checkbox :localdata="localdata_edition_force" @change="change_edition_force"
						:value="find.edition_force" mode="default"></uni-data-checkbox>
				</view>
			</view>
			<view class="banmi_input_edit" style="margin-left: 220rpx;">
				<text class="cred f-14">*如设置强制,则不显示关闭按钮</text>
			</view>
			<view class="banmi_input_edit a-c">
				<view class="banmi_input_edit_name">
					<text class="cred">*</text>安装包类型
				</view>
				<view class="banmi_input_val">
					<uni-data-checkbox :localdata="localdata_package_type" @change="change_package_type"
						:value="find.package_type" mode="default"></uni-data-checkbox>
				</view>
			</view>
			<template v-if="this.find.package_type==1">
				<view class="banmi_input_edit a-c">
					<view class="banmi_input_edit_name">
						<text class="cred">*</text>静默更新
					</view>
					<view class="banmi_input_val">
						<uni-data-checkbox :localdata="localdata_edition_silence" @change="change_edition_silence"
							:value="find.edition_silence" mode="default"></uni-data-checkbox>
					</view>
				</view>
				<view class="banmi_input_edit" style="margin-left: 220rpx;">
					<text class="cred f-14">*.wgt可设置静默更新，更新完重启生效</text>
				</view>
			</template>


			<view class="banmi_input_edit a-c">
				<view class="banmi_input_edit_name">
					<text class="cred">*</text>系统类型
				</view>
				<view class="banmi_input_val">
					<uni-data-checkbox :localdata="localdata_device" @change="change_device" :value="find.device"
						mode="default"></uni-data-checkbox>
				</view>
			</view>


			<view class="a-c  p-b-20 banmi_input_edit">
				<view class="banmi_input_edit_name">
				</view>
				<view class="">
					<button @click="on_sava()" type="primary" style="width: 80px;" size="mini">保存</button>
				</view>
			</view>

		</uni-popup-input>
		<!-- 	颜色选择器 -->
		<t-color-picker ref="colorPicker" @confirm="confirm_color"></t-color-picker>
	</view>
</template>

<script>
	import provinceData from '@/components/fd-picker/city-china.json';
	var find = {
		describe: '',
		edition_url: '',
		edition_number: '',
		edition_name: '',
		edition_issue: 0,
		edition_force: 0,
		package_type: 0,
		edition_silence: 0,
		device: 'android',
		create_time: '',

	};
	export default {
		components: {},
		props: {

		},
		data() {
			return {
				find: {},
				localdata_edition_issue: [{
					'value': 0,
					'text': '否',
				}, {
					'value': 1,
					'text': '是',
				}, ],
				localdata_edition_force: [{
					'value': 0,
					'text': '否',
				}, {
					'value': 1,
					'text': '是',
				}, ],
				localdata_package_type: [{
					'value': 0,
					'text': '整包升级',
				}, {
					'value': 1,
					'text': 'wgt热更新',
				}, ],
				localdata_edition_silence: [{
					'value': 1,
					'text': '静默更新',
				}, {
					'value': 0,
					'text': '提示更新',
				}, ],
				localdata_device: [{
					'value': 'android',
					'text': '安卓',
				}, {
					'value': 'ios',
					'text': '苹果',
				}, ],
				is_init: false,
				nav_list: [],
				img_url: '',
				arr_val: [{
						"value": '1',
						"text": "按钮1",
					},
					{
						"value": "2",
						"text": "按钮2",
					},
					{
						"value": "3",
						"text": "按钮3",
					},
				],
				provinceData: provinceData, //本地省市区数据 
				screenWidth: 0,

			}
		},

		methods: {

			confirm_describe(val) {
				this.find.describe = val;
			},
			change_edition_issue(e) {
				this.find.edition_issue = e.detail.value;
			},
			change_edition_force(e) {
				this.find.edition_force = e.detail.value;
			},
			change_package_type(e) {
				this.find.package_type = e.detail.value;
				if (this.find.package_type == 0) {
					this.find.edition_silence = 0;
				}
			},
			change_edition_silence(e) {
				this.find.edition_silence = e.detail.value;
			},
			change_device(e) {
				this.find.device = e.detail.value;
			},
			async on_sava() {
				var that = this;
				this.find.id = this.id
				this.find.catalogue = this.plugin_catalogue

				const ret = await this.Banmikeji.Appup_edit(this.find);
				uni.showToast({
					title: ret.msg,
					icon: 'none'
				})
				if (ret.status == 200) {
					this.$emit("confirm");
					this.on_close();
				}


			},
			async init(id, plugin_catalogue) {
				this.plugin_catalogue = plugin_catalogue;
				var that = this;
				that.id = id
				if (that.id == 0) {
					this.find = {
						describe: '',
						edition_url: '',
						edition_number: '',
						edition_name: '',
						edition_issue: 0,
						edition_force: 0,
						package_type: 0,
						edition_silence: 0,
						device: 'android',
						create_time: '',

					};
					this.is_init = true;
					return
				}
				let requestParams = {
					id: that.id,
				};
				const ret = await this.Banmikeji.Appup_views(requestParams);
				if (ret.status == 200) {
					this.find = ret.data.find;
					this.is_init = true;
					return
				}
				uni.showToast({
					title: ret.msg,
					duration: 2000,
					icon: 'error'
				});

			},

			on_close() {
				this.find = {};
				this.is_init = false;
			},
			//js分类方法

		}
	}
</script>

<style>
	button::after {
		border: none;
	}

	.top_head {
		background-color: #F8F8F8;
		width: 100%;
		top: 0;
		left: 0;
		z-index: 999;
		position: sticky
	}

	.but {
		width: 120rpx;
		height: 100rpx;
		padding: 0;
		border: 0;
		background-color: transparent;
		outline: none;
	}
</style>